package cn.xinfei.xdecision.data.core.frame.executors;

import cn.xinfei.xdecision.common.model.datax.enums.ExecutorEnum;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public abstract class AbstractExecutorFactory<IN, INOUT extends IExecutorInput> implements IExecutorInputFactory<IN, IExecutorInput> {

    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractExecutorFactory.class);

    @Override
    public IExecutorInput buildExecutorInput(IN in) {
        ExecutorEnum executorEnum = getExecutorEnums();
        switch (executorEnum) {
            case HTTP:
                LOGGER.info("Build Http Executor input,interfaceId: {}", JSONObject.toJSONString(in));
                break;
            case SQL:
                LOGGER.info("Build SQL Executor input,inputData: {}", JSONObject.toJSONString(in));
                break;
            case GROOVY_PRE:
                LOGGER.info("Build Groovy Executor input,inputData: {}", JSONObject.toJSONString(in));
                break;
            default:
                break;
        }
        return buildInput(in);
    }

    public abstract INOUT buildInput(IN in);

}
